package org.redmaple.core.template.dto;

import java.io.Serializable;

import org.redmaple.core.template.model.BaseModel;
import org.redmaple.core.util.Data7ViewerConvert;

@SuppressWarnings("serial")
public class BaseDTO  implements Serializable{
	
	private String id;
	private String createTime;
	
	public BaseDTO() {

	}
	
	public BaseDTO(BaseModel model) throws NoSuchMethodException {
		Data7ViewerConvert.convert(model, this);
	}
	
	public String getId() {
		return id;
	}
	public void setId(String id) {
		this.id = id;
	}
	
	public String getCreateTime() {
		return createTime;
	}
	public void setCreateTime(String createTime) {
		this.createTime = createTime;
	}
	
	@SuppressWarnings("unchecked")
	public <X extends BaseDTO> X convert(BaseModel model){
		try {
			if(model != null){
				Data7ViewerConvert.convert(model, this);
				return (X) this;
			}else {
				return null;
			}
			
		} catch (NoSuchMethodException e) {
			e.printStackTrace();
			return null;
		}
		
	}
}
